package com.boliq.lol.ui.fragment;


import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.boliq.lol.R;
import com.boliq.lol.adapter.CloudTopAdapter;
import com.boliq.lol.adapter.NewsAdapter;
import com.boliq.lol.base.BaseFragment;
import com.boliq.lol.bean.CloudTopBean;
import com.boliq.lol.bean.NewsBean;

import java.util.ArrayList;
import java.util.List;

public class CloudTopFragment extends BaseFragment implements View.OnClickListener {
    private RecyclerView listView;
    private CloudTopAdapter adapter;
    ImageView iv1;
    ImageView iv2;
    ImageView iv3;
    ImageView iv4;
    TextView iv5;
    TextView iv6;
    @Override
    protected int rootLayout() {
        return R.layout.fragment_cloud_top;
    }

    @Override
    protected void initView(View view) {
        iv1=view.findViewById(R.id.im1);
        iv2=view.findViewById(R.id.im2);
        iv3=view.findViewById(R.id.im3);
        iv4=view.findViewById(R.id.im4);
        iv1.setOnClickListener(this);
        iv2.setOnClickListener(this);
        iv3.setOnClickListener(this);
        iv4.setOnClickListener(this);
        listView = view.findViewById(R.id.rv_news_content);
        listView.setLayoutManager(new LinearLayoutManager(getActivity()));

        iv5=view.findViewById(R.id.im5);
        iv5.setOnClickListener(this);

        iv6=view.findViewById(R.id.im6);
        iv6.setOnClickListener(this);

        adapter = new CloudTopAdapter();

        adapter.setList(init());
        listView.setAdapter(adapter);

    }
    //这里适用于模拟数据创建的假数据
    private String[] title = new String[]{
            "【天神裁决天使】4裁决4天神2宗师",
            "【重装拉夫】4重装3龙魂3战神",
            "【七法龙王】7法师3龙魂3森林",
            "【重秘神射】4神射2重装2秘术",
            "【决战宗师】6决斗2玉剑2宗师",
            "【神盾凯南】6神盾3森林3腥红"
    };
    private String[] username = new String[]{
            "斗鱼|大仙儿",
            "虎牙奥莎娜",
            "斗鱼|七法龙王",
            "虎牙|king亚索",
            "斗鱼|梨落秋溪",
            "虎牙|Double可乐"
    };
    private int[] cover = new int[]{
            R.drawable.vateral_1,
            R.drawable.vateral_2,
            R.drawable.vateral_3,
            R.drawable.vateral_4,
            R.drawable.vateral_5,
            R.drawable.vateral_6,
            R.drawable.vateral_7,
            R.drawable.vateral_8
    };
        List<Integer>image=new ArrayList<>();

    private List<CloudTopBean> init() {
        image.add(R.mipmap.hero1);
        image.add(R.mipmap.hero2);
        image.add(R.mipmap.hero3);
        image.add(R.mipmap.hero4);
        image.add(R.mipmap.hero5);
        image.add(R.mipmap.hero6);
        image.add(R.mipmap.hero7);
        image.add(R.mipmap.hero8);

        List<CloudTopBean> list = new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            list.add(new CloudTopBean(title[i % title.length],username[i%username.length],
                  image,R.drawable.icon_tianguan4 ));

        }
        return list;
    }
    @Override
    protected void initData() {


    }

    @Override
    protected void bindEvent() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.im1:
                Toast.makeText(getActivity(),"模拟器",Toast.LENGTH_SHORT).show();
                break;
            case R.id.im2:
                Toast.makeText(getActivity(),"数据榜",Toast.LENGTH_SHORT).show();

                break;
            case R.id.im3:
                Toast.makeText(getActivity(),"资料库",Toast.LENGTH_SHORT).show();

                break;
            case R.id.im4:
                Toast.makeText(getActivity(),"实战助手",Toast.LENGTH_SHORT).show();
                break;
            case R.id.im5:
                Toast.makeText(getActivity(),"阵容推荐",Toast.LENGTH_SHORT).show();
                break;
            case R.id.im6:
                Toast.makeText(getActivity(),"资料纵观",Toast.LENGTH_SHORT).show();
                break;
        }

    }
}
